﻿@model WishlistModel
@using Nop.Web.Models.ShoppingCart;
@{
    Layout = "~/Views/Shared/_Root.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.Wishlist").Text);
}
<div class="page wishlist-page">
    <div class="page-title">
        <h1>
            @if (Model.IsEditable)
            {
                @T("Wishlist")
            }
            else
            {
                @String.Format(T("Wishlist.WishlistOf").Text, Model.CustomerFullname);
            }
        </h1>
    </div>
    <div class="page-body">
        <div class="wishlist-content">
            @if (Model.Items.Count > 0)
            {
                if (Model.Warnings.Count > 0)
                {
                <div class="message-error">
                    <ul>
                        @for (int i = 0; i < Model.Warnings.Count; i++)
                        {
                            <li>@Model.Warnings[i]</li>
                        }
                    </ul>
                </div>
                }
@*set "data-ajax" attribute to "false"*@
                using (Html.BeginRouteForm("Wishlist", FormMethod.Post,
                    new Dictionary<string, Object> { { "data-ajax", "false" } }))
                {
                <div class="cart">
                    <ul data-role="listview" data-inset="true" data-filter="false" data-theme="c">
                        @foreach (var item in Model.Items)
                        {
                            <li>
                                <div class="cart-item-row">
                                    <div class="product">
                                        <a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })" title="View details">@item.ProductName</a>
                                        @if (!String.IsNullOrEmpty(item.AttributeInfo))
                                        {
                                            <div class="attributes">
                                                @Html.Raw(item.AttributeInfo)
                                            </div>
                                        }
                                        @if (!String.IsNullOrEmpty(item.RecurringInfo))
                                        {
                                            <div class="recurring-info">
                                                @Html.Raw(item.RecurringInfo)
                                            </div>
                                        }
                                        @if (item.Warnings.Count > 0)
                                        {
                                            <div class="message-error">
                                                <ul>
                                                    @for (int i = 0; i < item.Warnings.Count; i++)
                                                    {
                                                        <li>@item.Warnings[i]</li>
                                                    }
                                                </ul>
                                            </div>
                                        }
                                    </div>
                                    @if (Model.ShowSku && !String.IsNullOrEmpty(item.Sku))
                                    {
                                        <div class="sku">
                                            @T("ShoppingCart.SKU"): @item.Sku
                                        </div>
                                    }
                                    <div class="unitprice">
                                        @T("ShoppingCart.UnitPrice"): @item.UnitPrice
                                    </div>
                                    <div class="quantity">
                                        @T("ShoppingCart.Quantity"):
                                        @if (Model.IsEditable)
                                        {
                                            if (item.AllowedQuantities.Count > 0)
                                            {
                                            <select name="itemquantity@(item.Id)" class="qty-dropdown"  data-mini="true" data-inline="true">
                                                @foreach (var qty in item.AllowedQuantities)
                                                {
                                                    <option selected="@qty.Selected" value="@qty.Value">@qty.Value</option>
                                                }
                                            </select>
                                            }
                                            else
                                            {
                                            <input name="itemquantity@(item.Id)" type="text" value="@(item.Quantity)" class="qty-input" />
                                            }
                                        }
                                        else
                                        {
                                            <span>@item.Quantity</span>
                                        }
                                    </div>
                                    <div class="totalprice">
                                        @T("ShoppingCart.ItemTotal"): @item.SubTotal
                                        @if (!String.IsNullOrEmpty(item.Discount))
                                        {
                                            <div class="discount">
                                                @T("ShoppingCart.ItemYouSave"): @item.Discount
                                            </div>
                                        }
                                    </div>
                                    @if (Model.IsEditable)
                                    {
                                        <div class="updateitem">
                                            <input type="submit" name="updatecartitem-@(item.Id)" value="@T("ShoppingCart.UpdateCartItem")" />
                                        </div>
                                        <div class="remove">
                                            <input type="submit" name="removefromcart-@(item.Id)" value="@T("ShoppingCart.Remove")" />
                                        </div>
                                    }
                                    @if (Model.DisplayAddToCart)
                                    {
                                        <div class="addtocart">
                                            <input type="submit" name="addtocart-@(item.Id)" value="@T("ShoppingCart.AddToCart")" />
                                        </div>
                                    }
                                </div>
                            </li>
                        }
                    </ul>
                </div>                     
                <div>
                    @if (Model.IsEditable)
                    {
                        <div class="common-buttons">
                            @if (Model.EmailWishlistEnabled)
                            {
                                <a href="@Url.RouteUrl("EmailWishlist")" data-role="button">@T("Wishlist.EmailAFriend")</a>
                            }
                        </div>
                    }
                </div>        
                }
            }
            else
            {
                @T("Wishlist.CartIsEmpty")
            }
        </div>
        @if (Model.IsEditable && Model.Items.Count > 0)
        {
            <div class="share-info">
                <p>
                    <span class="share-label">@T("Wishlist.YourWishlistURL"):</span>
                </p>
                <p>
                    <a href="@Url.RouteUrl("Wishlist", new { customerGuid = Model.CustomerGuid })" class="share-link">@Url.RouteUrl("Wishlist", new { customerGuid = Model.CustomerGuid }, "http")</a>
                </p>
            </div>
        }
    </div>
</div>
